1. Field of the Invention
The present invention relates generally to computer systems and software and more particularly to multi-threaded computing.
2. Description of the Background Art
A thread, composed of a context and a sequence of instructions to execute, may be defined as an independent flow of control within a process. The context may comprise a register set and a program counter.
A thread model operating system is capable of managing single threaded as well as multi-threaded processes. As described in “Thread Time: A Multithreaded Programming Guide” by Scott J. Norton and Mark D. DiPasquale, Prentice Hall, 1997, there are different types of thread models.
A many-to-one (M×1) thread model may also be referred to as a user threads implementation. The M×1 model is implemented in user space and does not necessarily require kernel modifications to support single-threaded as well as multithreaded processes. In the M×1 model, there can be many user threads, but only one kernel-scheduled entity (i.e. only one kernel thread). When the kernel scheduler selects a multithreaded process to run, the user scheduler in the threads library may plug in the context of the highest priority, runnable user thread. The kernel process then executes on behalf of that thread. While the kernel views the M×1 model process as single threaded, the threads library scheduler can switch between runnable threads in the process.
A 1×1 thread model (sometimes referred to as N×N) is generally implemented in kernel space rather than in user space. Hence, this model may be referred to as a kernel threads implementation. In the 1×1 model, there is one kernel thread for every user thread. Each user thread is permanently bound to a corresponding kernel-scheduled entity (i.e. to a corresponding kernel thread). The kernel thread can execute kernel code or system calls on behalf of its corresponding user thread. This model utilizes the kernel scheduler only; the user space scheduler is not needed.
The M×N thread model is implemented in both user and kernel space. Like the 1×1 model, the M×N model requires kernel modifications and so may be referred to as a kernel threads implementation. In the M×N model, there can be many user threads and any number of kernel threads. The M×N model allows user threads to be multiplexed on top of kernel threads or to be bound to kernel threads as necessary to suit program requirements. In addition to the kernel scheduler, the M×N model utilizes the user space scheduler to schedule user threads to run on kernel threads available in the process. The kernel scheduler schedules kernel threads to run on processors available in the system.